package com.he.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.he.entity.Cook;
import com.he.entity.User;
import com.he.mapper.CookMapper;
import com.he.service.CookService;
import com.he.util.PageBean;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class CookServiceImpl extends ServiceImpl<CookMapper, Cook> implements CookService {
    @Autowired
    private CookMapper cookMapper;

    @Override
    public PageBean<Cook> pageList(int pageNum, int pageSize, String foodName, String foodType) {
        PageBean<Cook> pb = new PageBean<>();

        //开启分页查询
        PageHelper.startPage(pageNum,pageSize);

        List<Cook> list = cookMapper.pageList(foodName,foodType);
        Page<Cook> p = (Page<Cook>) list;

        pb.setTotal(p.getTotal());
        pb.setItems(p.getResult());
        return pb;
    }
}
